package com.appjishu.web.model;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;
import java.util.Optional;

@ApiModel("按照条件排名")
public class RankingListByAllCondition {
    @ApiModelProperty(value = "所有")
    List<Ranking> rankingByAll;
    @ApiModelProperty(value = "院级排名")
    List<Ranking> rankingByCollegeId;
    @ApiModelProperty(value = "专业排名")
    List<Ranking> rankingBySpecialityId;
    @ApiModelProperty(value = "班级排名")
    List<Ranking> rankingByClassId;

    public List<Ranking> getRankingByAll() {
        return rankingByAll;
    }

    public void setRankingByAll(List<Ranking> rankingByAll) {
        this.rankingByAll = rankingByAll;
    }

    public List<Ranking> getRankingByCollegeId() {
        return rankingByCollegeId;
    }

    public void setRankingByCollegeId(List<Ranking> rankingByCollegeId) {
        this.rankingByCollegeId = rankingByCollegeId;
    }

    public List<Ranking> getRankingBySpecialityId() {
        return rankingBySpecialityId;
    }

    public void setRankingBySpecialityId(List<Ranking> rankingBySpecialityId) {
        this.rankingBySpecialityId = rankingBySpecialityId;
    }

    public List<Ranking> getRankingByClassId() {
        return rankingByClassId;
    }

    public void setRankingByClassId(List<Ranking> rankingByClassId) {
        this.rankingByClassId = rankingByClassId;
    }

    public Integer getRankByAll(Long userId) {
        int total = rankingByAll.size();
        Optional<Ranking> rank = rankingByAll.stream().filter(item -> item.getId().equals(userId)).findFirst();
        return rank.isPresent() ? rank.get().getRanking() : total + 1;
    }

    public Integer getRankingByCollegeId(Long userId) {
        int total = rankingByAll.size();
        Optional<Ranking> rank = rankingByAll.stream().filter(item -> item.getId().equals(userId)).findFirst();
        return rank.isPresent() ? rank.get().getRanking() : total + 1;
    }
    public Integer getRankingBySpecialityId(Long userId) {
        int total = rankingByAll.size();
        Optional<Ranking> rank = rankingByAll.stream().filter(item -> item.getId().equals(userId)).findFirst();
        return rank.isPresent() ? rank.get().getRanking() : total + 1;
    }
    public Integer getRankingByClassId(Long userId) {
        int total = rankingByAll.size();
        Optional<Ranking> rank = rankingByAll.stream().filter(item -> item.getId().equals(userId)).findFirst();
        return rank.isPresent() ? rank.get().getRanking() : total + 1;
    }

    @Override
    public String toString() {
        return "RankingListByAllCondition{" +
                "rankingByAll=" + rankingByAll +
                ", rankingByCollegeId=" + rankingByCollegeId +
                ", rankingBySpecialityId=" + rankingBySpecialityId +
                ", rankingByClassId=" + rankingByClassId +
                '}';
    }

}
